<template>
	<view class="boxflx">
		<view class="boxList">
			<view class="label">
				<view class="bo">

				</view>
				<view>{{listobjQ.typ}}流量</view>
			</view>
			<view class="charts-box">
				<qiun-data-charts type="mount" :opts="opts" :chartData="chartData" :ontouch="true" />
			</view>
		</view>
	</view>
</template>

<script>
	import dayjs from '@/common/dayjs.min.js';
	export default {
		props: {
			listobjQ: {
				type: [Object],
				default:()=>{ return {} }    
			},
		},
		data() {
			return {
				chartData: {},
				//这里的 opts 是图表类型 type="mount" 的全部配置参数，您可以将此配置复制到 config-ucharts.js 文件中下标为 ['mount'] 的节点中来覆盖全局默认参数。实际应用过程中 opts 只需传入与全局默认参数中不一致的【某一个属性】即可实现同类型的图表显示不同的样式，达到页面简洁的需求。
				opts: {
					timing: "easeOut",
					duration: 1000,
					rotate: false,
					rotateLock: false,
					color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4",
						"#ea7ccc"
					],
					padding: [15, 15, 0, 5],
					fontSize: 13,
					fontColor: "#666666",
					dataLabel: true,
					dataPointShape: true,
					dataPointShapeType: "solid",
					touchMoveLimit: 60,
					enableScroll: true,
					enableMarkLine: false,
					legend: {
						show: false,
						position: "bottom",
						float: "center",
						padding: 5,
						margin: 5,
						backgroundColor: "rgba(0,0,0,0)",
						borderColor: "rgba(0,0,0,0)",
						borderWidth: 0,
						fontSize: 13,
						fontColor: "#666666",
						lineHeight: 11,
						hiddenColor: "#CECECE",
						itemGap: 10
					},
					xAxis: {
						disableGrid: true,
						disabled: false,
						axisLine: true,
						axisLineColor: "#CCCCCC",
						calibration: false,
						fontColor: "#666666",
						fontSize: 13,
						lineHeight: 20,
						marginTop: 0,
						rotateLabel: false,
						rotateAngle: 45,
						itemCount: 5,
						boundaryGap: "center",
						splitNumber: 5,
						gridColor: "#CCCCCC",
						gridType: "solid",
						dashLength: 4,
						gridEval: 1,
						scrollShow: false,
						scrollAlign: "left",
						scrollColor: "#A6A6A6",
						scrollBackgroundColor: "#EFEBEF",
						title: "",
						titleFontSize: 13,
						titleOffsetY: 0,
						titleOffsetX: 0,
						titleFontColor: "#666666",
						format: ""
					},
					yAxis: {

						data: [{
							min: 0,
							title: ""
						}],
						disabled: false,
						disableGrid: false,
						splitNumber: 5,
						gridType: "solid",
						dashLength: 8,
						gridColor: "#CCCCCC",
						padding: 10,
						showTitle: true
					},
					extra: {
						mount: {
							type: "mount",
							widthRatio: 1.5,
							borderWidth: 1,
							barBorderCircle: false,
							linearType: "none",
							linearOpacity: 1,
							colorStop: 0
						},
						tooltip: {
							showBox: true,
							showArrow: true,
							showCategory: false,
							borderWidth: 0,
							borderRadius: 0,
							borderColor: "#000000",
							borderOpacity: 0.7,
							bgColor: "#000000",
							bgOpacity: 0.7,
							gridType: "solid",
							dashLength: 4,
							gridColor: "#CCCCCC",
							boxPadding: 3,
							fontSize: 13,
							lineHeight: 20,
							fontColor: "#FFFFFF",
							legendShow: true,
							legendShape: "auto",
							splitLine: true,
							horizentalLine: false,
							xAxisLabel: false,
							yAxisLabel: false,
							labelBgColor: "#FFFFFF",
							labelBgOpacity: 0.7,
							labelFontColor: "#666666"
						},
						markLine: {
							type: "solid",
							dashLength: 4,
							data: []
						}
					}
				}
			}
		},
		onLoad() {

		},
		methods: {
			onloshow() {
				this.chartData = {}
				if(!(uni.$u.test.isEmpty(this.listobjQ.list))){
					this.getServerData();
				}
				let now = dayjs();
				// 当前时间减去2小时
				this.times13 = now.subtract(0, 'hour').format('HH') + ":" + "00"
				this.times12 = now.subtract(2, 'hour').format('HH') + ":" + "00"
				this.times11 = now.subtract(4, 'hour').format('HH') + ":" + "00"
				this.times10 = now.subtract(6, 'hour').format('HH') + ":" + "00"
				this.times9 = now.subtract(8, 'hour').format('HH') + ":" + "00"
				this.times8 = now.subtract(10, 'hour').format('HH') + ":" + "00"
				this.times7 = now.subtract(12, 'hour').format('HH') + ":" + "00"
				this.times6 = now.subtract(14, 'hour').format('HH') + ":" + "00"
				this.times5 = now.subtract(16, 'hour').format('HH') + ":" + "00"
				this.times4 = now.subtract(18, 'hour').format('HH') + ":" + "00"
				this.times3 = now.subtract(20, 'hour').format('HH') + ":" + "00"
				this.times2 = now.subtract(22, 'hour').format('HH') + ":" + "00"
				this.times1 = now.subtract(24, 'hour').format('HH') + ":" + "00"
			},
			getServerData() {
				// 今日
				setTimeout(() => {
				let listArr = this.listobjQ.list.map((i) => {
					return {
						name: dayjs(i.time).format('MM-DD HH:mm'),
						value: i.value
					}
				})
				let res = {
					series: [{
						data: [{
							"name": "",
							"value": 0
						}]
					}]
				}
				 res.series[0].data  = listArr
				 this.chartData = res
				}, 300)
			},
		}
	};
</script>

<style scoped lang="scss">
	.boxflx {
		padding: 20rpx;

		.boxList {
			.label {
				padding: 15rpx 15rpx 15rpx 30rpx;
				display: flex;
				align-items: center;
				font-size: 40rpx;
				border-radius: 20rpx;
				border-bottom: 1rpx dashed #cfcfcf;
				background-color: #fff;
				box-shadow: 0rpx 0rpx 10rpx 10rpx rgba(125, 125, 125, 0.1);

				.bo {
					width: 12rpx;
					height: 40rpx;
					border-radius: 50rpx;
					margin-right: 20rpx;
					background-color: #76859c;
				}
			}

			.charts-box {
				width: 100%;
				height: 200px;
				padding-top: 20rpx;
				border-radius: 20rpx;
				background-color: #ffffff;
				border-top: 1rpx dashed #cfcfcf;
				box-shadow: 0rpx 0rpx 10rpx 10rpx rgba(125, 125, 125, 0.1);
			}

		}
	}
</style>
<style>
	page {
		background-color: #e8e8e8;
	}
</style>